<?php
/**
 * Project: AIGC
 * Author: moufer <moufer@163.com>
 * Date: 2024/7/20 00:12
 */

namespace module\chat\model;

use mof\Model;

class Category extends Model
{
    protected $name = 'chat_category';

    protected $type = [
        'icon' => 'storage'
    ];

    protected array $searchFields = [
        'id'     => 'integer',
        'type'   => 'string',
        'name'   => ['string', 'op' => 'like'],
        'status' => ['integer', 'zero' => true],
    ];

    protected $scene = [
        'simplify' => [
            'visible' => ['id', 'name', 'icon']
        ]
    ];

    public static function getTypeList(): array
    {
        return [
            'assistant' => '创作助手',
            'visrole'   => '虚拟角色',
        ];
    }

    public static function getListByType(string $string): array|\think\Collection
    {
        return self::where('type', $string)
            ->where('status', 1)
            ->order('listorder', 'desc')
            ->select();
    }
}